<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <title>维修保养</title>
    <link rel="stylesheet" href="../../css/api.css">
    <link rel="stylesheet" href="../../css/vant.css">
    <link rel="stylesheet" href="../../css/main.css">
    <style>
        .van-tabs__line {
            width: .3rem !important;
        }
    </style>
</head>

<body>
    <div class="app" v-cloak>
        <div class="header-common">
            <div class="flex-x-s header">
                <span class="iconfont goback" @click="back">&#xe66f;</span>
                <div class="search flex-x-s" @click="goPage">
                    <span class="iconfont">&#xe71e;</span>
                    <input type="text" maxlength="20" placeholder="请搜索关键词" readonly>
                </div>
                <div class="search-btn" @click="goPage">搜索</div>
            </div>
            <van-tabs v-model="active" color="#666666" title-active-color="#333333" line-height="0px"
                @click="setFrameGroupIndex">
                <van-tab :title="item.val" v-for="(item,index) in channelList" :key="index"></van-tab>
            </van-tabs>
        </div>
    </div>
    <script src="../../script/api.js"></script>
    <script src="../../script/flexible.js"></script>
    <script src="../../script/fastclick.js"></script>
    <script src="../../script/vue.min.js"></script>
    <script src="../../script/iconfont.js"></script>
    <script src="../../script/vant.min.js"></script>
    <script src="../../script/common.js"></script>
    <script src="../../script/restful.js"></script>
    <script src="../../script/businessCommon.js"></script>
    <script src="../../script/vue-lazyload.js"></script>

    <script>
        apiready = function () {
            vm = new Vue({
                el: '.app',
                data: {
                    show: false,
                    active: 0,
                    channelList: [],
                    frames: [],
                    headerH: 0,
                    footerH: 0,
                },

                mounted() {
                    var header = $api.dom('.header-common');
                    this.headerH = $api.fixStatusBar(header);
                    setBDPageStart("行业资讯")
                    this.getChannelData()

                },
                methods: {
                    back() {
                        setBDPageEnd("行业资讯")
                        api.closeWin();
                    },
                    goPage() {
                        api.openWin({
                            name: 'industry_news_search',
                            url: 'industry_news_search.html',
                            bounces: false,
                        });
                    },
                    //获取频道
                    getChannelData() {
                        let vm = this
                        index.news("getNewsCategoryList")({ type: 11, status: 1 }, (ret) => {
                            vm.channelList = ret.data
                            console.log(JSON.stringify(ret.data))
                            vm.frames = []
                            vm.channelList.forEach(item => {
                                var framItem = {
                                    name: 'industry_news_frm',
                                    url: 'industry_news_frm.html',
                                    pageParam: {
                                        channelId: item.id
                                    }
                                }
                                vm.frames.push(framItem)
                            });
                            vm.openFrameGroup();
                        })
                    },
                    openFrameGroup() {
                        var vm = this;
                        api.openFrameGroup({
                            name: 'news_group',
                            rect: {
                                marginTop: vm.headerH ,
                            },
                            scrollEnabled: true,
                            frames: vm.frames,
                            preload: 3,
                        }, function (ret, err) {
                            vm.active = ret.index;
                        });
                    },
                    setFrameGroupIndex() {
                        api.setFrameGroupIndex({
                            name: 'news_group',
                            scroll: true,
                            index: this.active,
                            reload: true
                        });
                    },
                },
            })
            api.addEventListener({
                name: 'keyback'
            }, function (ret, err) {
                setBDPageEnd("行业资讯")
                api.closeWin();
            });
        }
    </script>
</body>

</html>